import { ColumnsType } from "@/components";
import { h } from "vue"
import { ElText } from "element-plus"

/**
 * Table 字段对应 Label
 */
export enum TableLabel {
    Id = "ID",
    Name = "门店名称",
    Code = "门店编码",
    Token = "门店令牌",
    Address = "门店地址",
    ManagerId = "门店管理员",
    Enable = "是否启用",
    PhoneNumber = "电话号码",
    CreatedAt = "创建时间",
    UpdatedAt = "更新时间",
}

/**
 * 操作 对应 Label
 */
export enum OperateLabel {
    BindManager = "绑定管理员",
    UpdateManager = "换绑管理员",
    UnbindManager = "解绑管理员",
}

/**
 * placeholder 对应 Label
 */
export enum PlaceholderLabel {
    Name = "请输入" + TableLabel.Name,
    Code = "请输入" + TableLabel.Code,
    Token = "请输入" + TableLabel.Token,
    Address = "请输入" + TableLabel.Address,
    PhoneNumber = "请输入" + TableLabel.PhoneNumber,
}

export const columns: ColumnsType[] = [
    {
        minWidth: 100,
        label: TableLabel.Id,
        prop: "Id"
    },
    {
        minWidth: 120,
        label: TableLabel.Name,
        prop: "Name"
    },
    {
        minWidth: 120,
        label: TableLabel.Code,
        prop: "Code"
    },
    {
        minWidth: 120,
        label: TableLabel.Token,
        prop: "Token"
    },
    {
        minWidth: 120,
        label: TableLabel.Address,
        prop: "Address"
    },
    {
        minWidth: 120,
        label: TableLabel.ManagerId,
        prop: "ManagerId",
        Slots: {
            default: "ManagerId"
        }
    },
    {
        minWidth: 120,
        label: TableLabel.Enable,
        prop: "Enable",
        formatter(row, column, cellValue) {
            return h(ElText, {
                tag: "b",
                type: cellValue ? "success" : "danger",
            }, () => cellValue ? "启用" : "禁用");
        },
    },
    {
        minWidth: 180,
        label: TableLabel.PhoneNumber,
        prop: "PhoneNumber",
    },
    {
        width: 180,
        DateFormat: true,
        sortable: true,
        label: TableLabel.CreatedAt,
        prop: "CreatedAt"
    },
    {
        width: 180,
        DateFormat: true,
        sortable: true,
        label: TableLabel.UpdatedAt,
        prop: "UpdatedAt"
    },
    {
        fixed: "right",
        width: 180,
        label: "操作",
        prop: "",
        Slots: {
            default: "operate"
        }
    }
]